// 商品相关
import request from '@/utils/request'

// 商品列表
export const goods = (params) => {
  return request({
    url: 'goods',
    method: 'GET',
    params
  })
}

// 删除商品
export const delGoods = (id) => {
  return request({
    url: `goods/${id}`,
    method: 'DELETE'
  })
}

// 商品分类
export const categories = (params) => {
  return request({
    url: 'categories',
    method: 'GET',
    params
  })
}

// 添加分类
export const addCategories = (data) => {
  return request({
    url: 'categories',
    method: 'POST',
    data
  })
}

// 删除分类
export const delCategories = (id) => {
  return request({
    url: `categories/${id}`,
    method: 'DELETE'
  })
}
// 根据id查询分类
export const CateDetail = (id) => {
  return request({
    url: `categories/${id}`,
    method: 'GET'
  })
}

// 编辑分类
export const editCate = (data) => {
  return request({
    url: `categories/${data.id}`,
    method: 'PUT',
    data
  })
}

// 参数列表
export const attributes = (params) => {
  return request({
    url: `categories/${params.id}/attributes`,
    method: 'GET',
    params
  })
}

// 添加商品
export const addGoods = (data) => {
  return request({
    url: 'goods',
    method: 'POST',
    data
  })
}

// 根据id查询商品信息
export const goodsDetail = (id) => {
  return request({
    url: `goods/${id}`,
    method: 'GET'
  })
}

// 修改商品信息
export const editGoods = (data) => {
  return request({
    url: `goods/${data.id}`,
    method: 'PUT',
    data
  })
}
